<?php
abstract class EmsModelObject
{
	//Primary key fo an object
	private $Id;
	public function Id()
	{	    
	    return $this->Id;
	}
	
	//ID shuld only be set by the constructor of child objects
	protected function SetId($value)
	{
		if(!isset($value))
			throw new Exception("ID of an object cannot be NULL or empty");
	    $this->id = $value;	            
	}
	
	
	/*
	 * This is a list with the names of Properties which are
	 * invalid. Property check is implemented within the classes 
	 */
	private $propertyErrors;
	public function PropertyErrors()
	{
	    return $this->propertyErrorrs;            
	}
	protected function SetPropertyErrors($value)
	{
		$this->propertyErrors = $value;
	}
	protected function AddPropertyError($value)
	{
		if($this->propertyErrors == null)
			$this->propertyErrors = array();
		if(is_array($value))
		{
			foreach($value as $item)
				array_push($this->propertyErrors, $item);
		}
		else
			array_push($this->propertyErrors, $value);
	}
	
	
	abstract public function __construct($entity);
	abstract public function IsValid();
	abstract public static function GetType();
	abstract public function SaveChanges();
}
?>